<?php
namespace app\admin\model;

use think\Model;

class Banner extends Base
{
    protected $name = 'banner';

    // 显示||隐藏
    public function setIsShow($id){
        $info = $this->getFind(['id' => $id])['data'];

        if($info['is_show'] == 0){
            $isShow       = 1;
            $back['flag'] = 1;
            $back['msg']  = '显示成功';
        }else{
            $isShow       = 0;
            $back['flag'] = 0;
            $back['msg']  = '隐藏成功';
        }

        $data = [
            'id'       => $id,
            'is_show'  => $isShow,
        ];
        
        $this->update($data);
        return $back;
    }

    public function getImgAttr($val){
        if(!$val){
            return '-';
        }

        return config('app.url') . $val;
    }
}